"""
@-*- coding: utf-8 -*-
@ python: 3.12.3
@ 创建者: JacksonCode
@ 创建时间: 2025-10-13
"""
import hmac
import hashlib


def hmac_(data, key):
    hash_obj = hashlib.sha256
    h = hmac.new(key.encode('utf-8'), data.encode('utf-8'), hash_obj)
    return h.hexdigest()


def new_hmac(data, key, s):
    hash_func = getattr(hashlib, s)
    h = hmac.new(key.encode('utf-8'), data.encode('utf-8'), hash_func)
    return h.hexdigest()


if __name__ == '__main__':
    ret = hmac_("123456", "md5")
    print(ret)
    res = new_hmac("123456", "md5","sha1")
    print(res)
